package cn.wolfcode.wolf2w.job;


import cn.wolfcode.wolf2w.redis.service.IStrategyStatisVORedisService;
import cn.wolfcode.wolf2w.redis.vo.StrategyStatisVO;
import cn.wolfcode.wolf2w.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

//@Component
public class RedisDataPersistenceJob {

    @Autowired
    private IStrategyStatisVORedisService strategyStatisVORedisService;
    @Autowired
    private IStrategyService strategyService;


    @Scheduled(cron = "0/5 * * * * ?")
    public void doWork(){
        System.out.println("-------攻略数据持久化--------");


        //查出所有vo对象
        List<StrategyStatisVO> strategyStatisVOS = strategyStatisVORedisService.queryStrategyVoByPattern("*");
        for (StrategyStatisVO strategyStatisVO : strategyStatisVOS) {
            strategyService.updateStrategyStatisVO(strategyStatisVO);
        }


    }


}
